import request from "@/utils/request";
import { OrgQuery, OrgVO, OrgForm } from "./types";
import { AxiosPromise } from "axios";

export function getOrgPage(
  queryParams?: OrgQuery
): AxiosPromise<PageResult<Org[]>> {
  return request({
    url: "/admin/organization/index",
    method: "get",
    params: queryParams,
  });
}

export function getData() {
  return request({
    url: "/admin/organization/tree",
    method: "get",
  });
}

export function orgTree(): AxiosPromise<OptionType[]> {
  return request({
    url: "/admin/organization/orgTree",
    method: "get",
  });
}

export function orgDisable(data: any) {
  return request({
    url: "/admin/organization/disable",
    method: "post",
    data,
  });
}

export function orgEnable(data: any) {
  return request({
    url: "/admin/organization/enable",
    method: "post",
    data,
  });
}

export function createOrg(data: any) {
  return request({
    url: "/admin/organization/add",
    method: "post",
    data,
  });
}

export function updateOrg(data: any) {
  return request({
    url: "/admin/organization/edit",
    method: "put",
    data,
  });
}

export function delOrg(data: any) {
  return request({
    url: "/admin/organization/del",
    method: "delete",
    data,
  });
}

export function getOrgForm(ids: number): AxiosPromise<OrgForm> {
  return request({
    url: "/admin/organization/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}
